#!/bin/bash

echo "===================================="
echo "   商家端Moco服务器启动器"
echo "===================================="
echo ""

# 检查Java是否安装
if ! command -v java &> /dev/null; then
    echo "[错误] 未检测到Java环境，请先安装Java JDK 8或更高版本"
    echo "下载地址: https://www.oracle.com/java/technologies/downloads/"
    exit 1
fi

# 检查moco-runner文件是否存在
if [ ! -f "moco-runner-1.3.0-standalone.jar" ]; then
    echo "[错误] 未找到moco-runner-1.3.0-standalone.jar文件"
    echo "请下载moco-runner: https://repo1.maven.org/maven2/com/github/dreamhead/moco-runner/1.3.0/moco-runner-1.3.0-standalone.jar"
    exit 1
fi

# 检查配置文件是否存在
if [ ! -f "merchant-api.json" ]; then
    echo "[错误] 未找到merchant-api.json配置文件"
    exit 1
fi

echo "[启动] 正在启动Moco服务器..."
echo "[端口] 8080"
echo "[配置] merchant-api.json"
echo ""
echo "提示: 按Ctrl+C停止服务器"
echo ""

# 启动Moco服务器
java -jar moco-runner-1.3.0-standalone.jar http -p 8080 -c merchant-api.json




